players={}
hooks = {}
htyp = {
		"startround",
		"kill",
		}
--Temp msg2(p, t)
function msg2(p, t)
	print (p, t)
end

--Temp msg(t)
function msg(t)
	print ("All",t)
end

--Temp pr(p, t)
function pr(t)
	print (t)
end

--Temp setMoney(p, i)
function setMoney(p, i)
	print (p, player(p, "name").."'s money changed by "..i)
end

--Temp player(p, arg)
function player(p, arg)
	--print (p,players[p])
	if not players[p] then return nil end
	return players[p][arg]

end

--Temp parse(t)
function parse(t)
	print("Srv","Server executed command: "..t)
end

--Temp sleep(t)
function sleep(t)
	print("Slp","Sleeping for "..t.." seconds")
	local ttime = os.clock()+t
	while (os.clock() < ttime) do
		--something?
	end
	return 1
end

--Temp createPlayer(arg)
function createPlayer(arg)
	local id = #players + 1
	--print (id)
	local name_ = arg[1]
	local team_ = arg[2]
	local health_ = arg[3]
	local money_ = arg[4]
	table.insert(players, {name = name_, team = team_, health = health_, money = money_})
end

--Temp addhook(hook, function_name)
function addhook(h, f)

	if type(_G[f]) == "function" then
		if not hooks[h] then hooks[h] = {} end
		table.insert(hooks[h], _G[f])
	end
end

--Temp initHooks(h)
function initHooks(h)
	local hook = {}
	if h then hook = {h} else hook = htyp end

	for i, v in ipairs(hook) do
		local modname = v
		if not _G["hook_"..modname] then
			_G["hook_"..modname] = function(n1, n2, n3, n4, n5, n6)
										if not hooks[modname] then return 0 end
										for i, fn in ipairs(hooks[modname]) do
											fn(n1, n2, n3, n4, n5, n6)
										end
									end
		end
	end
end

initHooks()
